#include "LCD12864.h"
#include "systick.h"

void IntDisplay(u16 data,u8 row,u8 column)
{
		unsigned char c[4]={'0','0','0'};
		if(data>99)
		{
			c[0]=c[0]+data/100%10;
			c[1]=c[1]+data/10%10;
			c[2]=c[2]+data%10;
		}
		if((data>9)&&(data<100))
		{
			c[0]=c[0]+data/10%10;
			c[1]=c[1]+data%10;
			c[2]=' ';
		}		
		if(data<10)
		{
			c[0]=c[0]+data%10;
			c[1]=' ';
			c[2]=' ';
		}			
		LCD_Display_Words(row,column,c);
		delay_ms(10);	
}
void IntDisplay2(u16 data,u8 row,u8 column)
{
		unsigned char c2[5]={'0','0','0','0'};
		if(data>999)
		{
			c2[0]=c2[0]+data/1000%10;
			c2[1]=c2[1]+data/100%10;
			c2[2]=c2[2]+data/10%10;
			c2[3]=c2[3]+data%10;
		}
		if((data>99)&&(data<1000))
		{
			c2[0]=c2[0]+data/100%10;
			c2[1]=c2[1]+data/10%10;
			c2[2]=c2[2]+data%10;
			c2[3]=' ';
		}				
		if((data>9)&&(data<100))
		{
			c2[0]=c2[0]+data/10%10;
			c2[1]=c2[1]+data%10;
			c2[2]=' ';
			c2[3]=' ';			
		}		
		if(data<10)
		{
			c2[0]=c2[0]+data%10;
			c2[1]=' ';
			c2[2]=' ';
			c2[3]=' ';			
		}			
		LCD_Display_Words(row,column,c2);
		delay_ms(10);	
}

void IntDisplay3(u16 data,u8 row,u8 column)
{
		unsigned char c2[2]={'0'};
			c2[0]=c2[0]+data%10;;	
		LCD_Display_Words(row,column,c2);
		delay_ms(10);	
}

void IntDisplay4(int data,u8 row,u8 column)
{
	u8 sign=0;
	unsigned char c[5]={'0','0','0','0'};
	
	if(data<0)
	{
		data=0-data;		
		sign=1;
	}		
		if(data>99)
		{
			c[0]=' ';	
			c[1]=c[1]+data/100%10;
			c[2]=c[2]+data/10%10;
			c[3]=c[3]+data%10;
			if(sign==1)
				c[0]='-';
		}
		if((data>9)&&(data<100))
		{
			c[0]=' ';	
			c[1]=' ';	
			c[2]=c[2]+data/10%10;
			c[3]=c[3]+data%10;	
			if(sign==1)
				c[1]='-';			
		}		
		if(data<10)
		{
			c[0]=' ';
			c[1]=' ';
			c[2]=' ';
			c[3]=c[3]+data%10;
			if(sign==1)
				c[2]='-';
		}			
		LCD_Display_Words(row,column,c);
		delay_ms(10);	
}

void DisplayStructure(void)
{
		LCD_Display_Words(0,0,"NRF:");
		LCD_Display_Words(0,4,"CON:");			
}

void MenuDisplayStructure(void)
{
		LCD_Display_Words(0,0,"1 EXV");
		LCD_Display_Words(0,4,"2 SolVal");			
		LCD_Display_Words(1,0,"3 SerMt");
		LCD_Display_Words(1,4,"4 PWM");
		LCD_Display_Words(2,0,"5 ADC");
		LCD_Display_Words(2,4,"6 Other");
		LCD_Display_Words(3,0,"Select:");
	LCD_Display_Words(3,7," %");	
}
